#! /usr/bin/python3
# =*- coding:utf-8 -*-
import os

print(list(range(1, 11)))

L = []
for x in range(1, 11):
    L.append(x*x)
print(L)

L = [x*x for x in range(1, 11)]
print(L)
# 含有条件的列表生成
L = [x*x for x in range(1, 11) if x % 2 == 0]
print(L)

# 两层列表 循环
L = [m + n for m in 'ABC' for n in 'XYZ']
print(L)

L = [m + n for n in range(1, 3) for m in range(4, 6)]
L1 = [m + n for n in (1, 2) for m in (4, 5)]
L2 = [m * n for n in (1, 2) for m in (4, 5)]
print(L)
print(L1)
print(L2)
L = [d for d in os.listdir('.')]
L1 = [d for d in os.listdir('./')]
L2 = [d for d in os.listdir('../')]
print(L)
print(L1)
print(L2)


d = {'x': 'A', 'y': 'B', 'z': 'C'}
print(d)
for k, v in d.items():
    print(k, '=', v)

L = [k + '=' + v for k, v in d.items()]
print(L)

L = ['Hello', 'World', 'IBM', 'Apple']
print(L)
L = [s.lower() for s in L]
print(L)

L = ['Hello', 'World', 12, 'IBM', 16, 'Apple']


# 小写变大写
def doSlower(L):
    L = [sr.lower() for sr in L if isinstance(sr, str)]
    return L


print(doSlower(L))
l = []
for s in L:
    if isinstance(s, str):
        l.append(s.lower())
    else:
        l.append(s)
print(l)


L = []
for s in l:
    if isinstance(s, str):
        L.append(s.capitalize())      # 将字符串的首字母大写
    else:
        L.append(s)


print(L)
